<?php if(!empty($content)) :

  ?>

<div>
  <div class="sliderGallery">
    <?php (count($content) == 0) ? $width = '1000' : $width = count($content) * 174; ?>
    <ul style="width:<?php print $width.'px'?>">
      <?php
      foreach($content as $term) {
        if(isset($term -> field_image) && !empty($term -> field_image)) {
          $image = $term -> field_image;

          $link = db_select('field_revision_field_category', 'frfc')
            ->fields('frfc', array('entity_id'))
            ->condition('field_category_tid', $term->tid)
            ->range(0,1)
            ->execute()->fetchCol();
          (isset($link[0])) ? $link = $link[0] : $link = '';
          ?>
          <li>
            <?php
            print l('<p><img alt="" src="'.file_create_url($image["und"][0]["uri"]).'" style="width: 112px; height: 112px;" /></p><span>'.$term->name.'</span>',
              'node/'.$link, array('absulute' =>true, 'html' => true));
            ?>
          </li>
          <?php
        }
      }
      ?>
    </ul>
  </div>
  <div class="sliderOut">
    <div class="slidArrLeft"></div>
    <div class="slidArrRight"></div>
    <div class="slider">
      <div class="ui-slider-handle"></div>
    </div>
    <?php
    $nid = (int) arg(1);
    $active_node = node_load($nid);
    if(!empty($active_node) && count($content) > 0) {
      $trm = $active_node->field_category['und'][0]['taxonomy_term'];
      $position = 100 / (count($content) - 1) * $trm->weight;
    }
    ?>
    <input type="hidden" id="hfLeft" value='<?php print isset($position) ? $position : 0; ?>' />
  </div>
</div>
<?php endif; ?>
